home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16491 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: cypher.3do.com!user
  2. From: tsw@3do.com (Tom Watson)
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
  4. Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
  5. Date: Wed, 10 Apr 1996 18:37:31 -0800
  6. Organization: The 3DO Corporation
  7. Distribution: world
  8. Message-ID: <tsw-1004961837310001@cypher.3do.com>
  9. References: <JSA.96Feb16135027@organon.com> <4kb2j8$an0@solutions.solon.com>    <4kbrt5$k3h@mulga.cs.mu.OZ.AU> <dewar.829012486@schonberg>      <4kcpgkINNcku@keats.ugrad.cs.ubc.ca> <TYNOR.96Apr9105114@twratl.atlanta.twr.com> <4kgunm$o4o@gde.GDEsystems.COM>
  10. NNTP-Posting-Host: cypher.3do.com
  11.  
  12. In article <4kgunm$o4o@gde.GDEsystems.COM>, Chet <kackman> wrote:
  13.  
  14. > If i = j depends on your unit of address. If i is assumed a longword then
  15. >      &i + 4 = &j is true
  16. >      not 
  17. >      &i + 1 = &j
  18. >       Chet
  19.  
  20. Bzzzzzt.  Sorry wrong answer, and thank you for playing the game.
  21.  
  22. Adding '1' to a pointer implies that you increment the address by the
  23. sizeof the object pointed to.
  24.  
  25. Why else is a[i] =(equivalent to)= *(a+i).
  26.  
  27. Now in the original example (deleted before this response) the second
  28. object 'j' in this case could be optimized into a register, if its address
  29. weren't taken somewhere.
  30.  
  31. All of this can explain why one can't do arithmetic on a 'void *' unless
  32. the compiler has made special (non-ANSI) arrangements.  Typically
  33. sizeof(void) is defined in the compiler as zero so this can't be done (and
  34. it produces an error!).
  35.  
  36. -- 
  37. Tom Watson
  38. tsw@3do.com         (Home: tsw@johana.com)
  39.